import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 石方旭
 * Date: 2022-05-02
 * Time: 14:09
 */


class Solution {
    public int canBeTypedWords(String text, String brokenLetters) {
        String[] result = text.split(" ");//按照空格分割
        int cnt =0;
        for(String s: result) {
            int flag =1;
            for(int i =0;i<brokenLetters.length();++i) {
                if(s.contains(brokenLetters.charAt(i)+"")) {
                    flag =0;
                }
            }
            if(flag==1) {
                ++cnt;
            }
        }
        return cnt;
    }
}
class Solution1 {
    public String removeDuplicates(String S) {
        int left = 0;
        int right = 0;
        int length = S.length();
        char[] chars = S.toCharArray();
        while (right < length) {
            //先把右边的字符赋值给左边
            chars[left] = chars[right];
            //然后判断左边挨着的两个字符是否相同，如果相同，
            //他两同时消失，也就是left往回退两步
            if (left > 0 && chars[left - 1] == chars[left])
                left -= 2;
            ++right;
            ++left;
        }
        return new String(chars, 0, left);
    }

    public String removeDuplicates1(String S) {
        StringBuilder stringBuilder = new StringBuilder();
        char[] chars = S.toCharArray();
        for (char ch : chars) {
            int size = stringBuilder.length();
            if (size > 0 && stringBuilder.charAt(size - 1) == ch) {
                stringBuilder.deleteCharAt(size - 1);
            } else {
                stringBuilder.append(ch);
            }
        }
        return stringBuilder.toString();
    }



    public int[] Count(String characterNumber) {
        int[] hash = new int[26];
        //    for(char c:characterNumber) {
        //         hash[c-'a']++;
        //    }
        for(int i =0;i<characterNumber.length();++i) {
            char c = characterNumber.charAt(i);
            hash[c-'a']++;
        }
        return hash;
    }

    public Boolean contains(int[] charsCount,int[] wordsCount) {
        for(int i =0;i<26;++i) {
            if(charsCount[i]<wordsCount[i]) {
                return false;
            }
        }
        return true;
    }

    public int countCharacters(String[] words, String chars) {
        //统计单词中的和chars的子母出现次数
        int[] charsCount=Count(chars);
        int ans =0;
        for(String s: words) {
            int[] wordsCount = Count(s);
                if(contains(charsCount,wordsCount)){
                    //满足charsCount>=wordsCount
                    ans+=s.length();
                }
        }
        return ans;
    }
}
public class LeetCode {


    public static void main(String[] args) {
        Solution solution = new Solution();
        solution.canBeTypedWords("leet code","lt");
    }

    public static void main3(String[] args) {
        String s = "world";
        String b = "ad";
        System.out.println(s.contains(b));
    }

//    public static void main2(String[] args) {
//        Solution solution = new Solution();
//        System.out.println(solution.removeDuplicates("abbaca"));
//    }
    public static void main1(String[] args) {
//        Solution solution = new Solution();
//        String[] words = {"cat","bt","hat","tree"};
//        String chars = "atach";
//        System.out.println(solution.countCharacters(words, chars));
//        String str ="world";
        List<String> list = new ArrayList<>();
        String s ="fghjk";
        list.add("a");
        list.add("b");
        list.add("b");
        list.add("a");
        list.add("a");
        list.add("a");
        list.add("a");
        list.add("b");
        list.add("b");
        list.add(s);
        char[] s1 = s.toCharArray();
        System.out.println(list);
        list.remove(s1[0]);
       // System.out.println(list);
    }


}
